<?php


namespace App\Models;


use Illuminate\Database\Eloquent\SoftDeletes;

class Address extends BaseModel
{
    use SoftDeletes;

    public static function userList($userId)
    {
        $list = self::where('user_id', $userId)->get();
        return $list;
    }

    public static function setAddressDefault($id, $userId)
    {
        self::where('user_id', $userId)->update(['is_default' => 0]);
        $result = self::editOne(['id' => $id], ['is_default' => 1])->save();
        return $result;
    }

    public static function details($id, $userId)
    {
        $item = self::where('user_id', $userId)->find($id);
        return $item;
    }
}